package cn.com.shbs.Service.SupplierInfoService;



import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.shbs.Dao.SupplierInfoDao.SupplierInfoDao;
import cn.com.shbs.Service.UserInfoService.UserInfoServiceImpl;
import cn.com.shbs.model.Store;
import cn.com.shbs.model.Supplier;

@Service
public class SupplierInfoServiceImpl implements ISupplierInfoService {

	static Logger logger = LoggerFactory.getLogger(UserInfoServiceImpl.class);
	@Autowired
	SupplierInfoDao supplierInfoDao;

	@Override
	public int findSupplierInfo_nums(String supplier_name) throws Exception {
		// TODO Auto-generated method stub

		logger.info("SupplierInfoServiceImpl.findSupplierInfo_nums() 方法 start");

		int supplier_nums = 0;

		try {
			
			supplier_nums = supplierInfoDao.findSupplierInfo_nums(supplier_name);

		} catch (Exception e) {
			// TODO: handle exception
			logger.error("SupplierInfoServiceImpl.findSupplierInfo_nums() ", e);
		}
		logger.info("SupplierInfoServiceImpl.findSupplierInfo_nums()  方法 end");
		return supplier_nums;
	}

	@Override
	public List<Supplier> findSupplierInfoByName(HashMap map) throws Exception {
		// TODO Auto-generated method stub
		
		List<Supplier> suppliers_list=null;
		
		try {

			suppliers_list=supplierInfoDao.findSupplierInfoByName(map);
			

		} catch (Exception e) {
			logger.error("SupplierInfoServiceImpl.findSupplierInfoByName()", e);
			throw e;
		}

		logger.info("SupplierInfoServiceImpl.findSupplierInfoByName() 方法 end");
		
		return suppliers_list;
		
	}

	@Override
	public void UpSupplierInfoById(Supplier supplier) throws Exception {
		// TODO Auto-generated method stub
		try {

			// 更新供应商信息
			supplierInfoDao.UpSupplierInfoById(supplier);

		} catch (Exception e) {
			logger.error("SupplierInfoServiceImpl.UpSupplierInfoById()", e);
			throw e;
		}

		logger.info("SupplierInfoServiceImpl.UpSupplierInfoById() 方法 end");
	}

	@Override
	public Supplier FindSupplierInfoById(String supplier_code) throws Exception {
		// TODO Auto-generated method stub
		
		Supplier supplier=new Supplier();
		
		try {

			// 更新供应商信息
			supplier=	supplierInfoDao.FindSupplierInfoById(supplier_code);

		} catch (Exception e) {
			logger.error("SupplierInfoServiceImpl.FindSupplierInfoById()", e);
			throw e;
		}

		logger.info("SupplierInfoServiceImpl.FindSupplierInfoById() 方法 end");
		
		return supplier;
	}



}
